
module NianShouGame{

    export class Game extends egret.DisplayObjectContainer {

        static instance:Game;

        public static Instance():Game{
            if (null == Game.instance){
                Game.instance = new Game();
            }
            return Game.instance;
        }


        private constructor(){
            super();
            this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
            this.catchSound = RES.getRes("Catch_mp3");
            this.mcCatch = new egret.MovieClipDataFactory(RES.getRes("CatchAnimClip_json"), RES.getRes("CatchAnimClip_png"));
        }

        private onAddToStage(event:egret.Event){
            if (!this.bEditor)
            {
                this.touchEnabled = true;
                this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBegin, this);
                this.addEventListener(egret.TouchEvent.TOUCH_END, this.onTouchEnd, this);
            }
            this.level = this.startLevel;
            this.CreateLevel();
        }

        // 创建关卡
        private CreateLevel()
        {            
            let dWidth = this.lastLevelWidth - this.firstLevelWidth;
            this.buildingWidth = this.firstLevelWidth + dWidth * this.level / 15;
            this.buildingHeight = this.buildingWidth * scal;
            
            // 200 84个

            let cityNum = this.createCity(scal);     // 创建城市   
            if(this.bEditor)
            {
                let editor = Editor.Instance();
                this.addChild(editor);
                Editor.Instance().CreateEditor();
            }
            if (this.bCreateFloat)
            {
                this.createFloatAnim(cityNum);        // 创建气球
            }
            this.Pointer = this.createPointer();
            // this.PlayCatchAnim(200, 200);  
            this.onTouchCallback(false);
        }


        // 创建UI
        private CreateGameUI()
        {
            if (this.bHasUI)
            {
                this.TextLevel = this.createTopUIGroup(100, 100, 40, "0");  // 创建UI
                this.TextLevel.text = this.level.toString();
                this.createTopUIGroup(400, 100, 40, "60s"); 
            }
        }        


        // 游戏结束
        private OnGameEnd()
        {
            // this.removeChildren();
            // this.$render();
        }

        // 重新从第一关开始游戏
        public ReStartGame():void
        {
            if(this.bDebugInfo)
            {
                console.log("Restart");
            }
            this.removeChildren();
            this.level = 0;
            this.CreateLevel();
            this.$render();
        }

        // 点击
        private onTouchBegin(e:egret.TouchEvent):void
        {
            if (null != this.Pointer)
            {
                this.addChild(this.Pointer);
                this.Pointer.x = e.stageX;
                this.Pointer.y = e.stageY;
            }
            // this.onTouchCallback(false);
        }

        private timerComFunc()
        {
            console.log("计时结束");
            this.level += 1;
            this.removeChildren();
            if (this.level >= this.levelNum)
            {
                if (this.bEditor)
                {
                    this.level = 0;
                    this.CreateLevel();
                }else
                {
                    this.OnGameEnd();
                }
            }else
            {
                this.CreateLevel();
            }

        }

        // 下一关
        public NextLevel():void
        {
            var timer:egret.Timer = new egret.Timer(1000, 1);
            timer.addEventListener(egret.TimerEvent.TIMER_COMPLETE,this.timerComFunc,this);
            timer.start();
        }

        public BeforeLevel():void
        {
            this.level -= 1;
            this.removeChildren();
            this.$render();
            if (this.level < 0)
            {
                if (this.bEditor)
                {
                    this.level = this.levelNum - 1;
                    this.CreateLevel();
                }else
                {
                    this.OnGameEnd();
                }
            }else
            {
                this.CreateLevel();
            }
        }

        // 点击回调接口
        public onTouchCallback(bCatch:boolean):boolean
        {
            catchCallback({
                x:this.Pointer.x,
                y:this.Pointer.y,
                isHited:bCatch,
                level:this.level + 1,
                levelAnimals:this.level + 1,
                levelLeftAnimals:this.currentPlayerNum,
            })
            return bCatch;
        }


        private onTouchEnd(e:egret.TouchEvent):void
        {
            if (null != this.Pointer)
            {
                this.removeChild(this.Pointer);
                this.Pointer.x = -100;
                this.Pointer.y = -100;
            }
        }
        
        // 地面：0 ~ 200
        // player 汽车 200 ~ 300
        // 建筑 300 ~ 500
        // 气球 500~


        // 画线
        private DrawLine(startX:number, startY:number, endX:number, endY:number)
        {
            let line = new egret.Shape();
            line.graphics.lineStyle(2, 0x00ff00);
            line.graphics.moveTo(startX, startY);
            line.graphics.lineTo(endX, endY);
            line.graphics.endFill();
            this.addChild(line);
            this.setChildIndex(line, 1000);
        }


        // 鼠标
        public createPointer():egret.Bitmap
        {
            let pointer = this.createBitmapByName("Pointer_png");
            pointer.width = pointer.width * this.pointerScale;
            pointer.height = pointer.height * this.pointerScale;
            pointer.anchorOffsetX = pointer.width / 2;
            pointer.anchorOffsetY = pointer.height / 2;
            pointer.x = -200;
            pointer.y = -200;
            this.addChild(pointer);
            this.setChildIndex(pointer, 500);
            return pointer;
        }
        

        // 创建城市
        public createCity(scal):number
        {
            let stageW = this.stage.stageWidth;
            let stageH = this.stage.stageHeight;

            // 车名字
            let carNames:string[]=["CAR1", "CAR2", "P1", "P2", "P3", "P4"];

            // 由图像大小和屏幕比例决定的行列数
            let ww = stageW / this.buildingWidth;
            let ceilww = Math.ceil(ww);
            this.row = Math.ceil(stageH / this.buildingHeight) * 2 + 1;   // 行
            this.col = ceilww - ww < 0.5 ? ceilww + 1 : ceilww;

            let bEven = true;       // 是否交错
            let carIndex = 0;       // 生成车的序列

            // 年兽位置
            // let playersR:number[] = [];
            // let playersC:number[] = [];
            // let playerR = Math.floor(Math.random() * (this.row - 1)); 
            // let playerC = Math.floor(Math.random() * (this.col - 1)); 


            // for (let r = 0; r < playerRow; r++)
            // {
            //     for (let c = 0; c < playerCol; c++)
            //     {
            //         // 得到行列位置
            //         let x = c * playerPosWidth - playerPosWidth * 0.5;
            //         let y = r * playerPosHeight - playerPosHeight * 0.5;

            //         let player = this.CreatePlayer(x, y); 
            //         this.FixPlayerPos(player, playerPosWidth, playerPosHeight);
            //         // if(this.bDebugPlayer)
            //         // {
            //         //     this.DrawLine(this.stage.stageWidth * 0.5, this.stage.stageWidth * 0.5, player.x, player.y);
            //         // }

            //     }
            // }

            let addIndex = 0;
            
            let playerList:egret.Bitmap[][] = [];
            this.playerWidth = this.buildingWidth * this.playerScale;
            if (!this.bEditor)
            {
                let playerCol = this.col * 2;
                let playerRow = this.row;
                let playerPosWidth = this.buildingWidth / 2;
                let playerPosHeight = this.buildingHeight / 2;
                if(this.bDebugInfo)
                {
                    console.log("关卡 " + this.level + "创建年兽");
                }
                this.currentPlayerNum = this.level + 1;

                // ---------------------------------- Fix Player Pos Range -----------------------------
                let maxC = playerCol - 1;
                for (let c = playerCol - 1; c >= 0; c--)
                {
                    let tempx = c * playerPosWidth + playerPosWidth * 0.5;
                    if (tempx < this.stage.stageWidth - this.playerWidth)
                    {
                        maxC = c;
                        break;
                    }
                }

                let minR = 0;
                let maxR = playerRow;
                for (let r = playerRow - 1; r >= 0; r--)
                {
                    let tempy = r * playerPosHeight + playerPosHeight * 0.5;
                    if (tempy < this.stage.stageHeight)
                    {
                        maxR = r;
                        break;
                    }
                }
                for (let r = 0; r < playerRow; r++)
                {
                    let tempy = r * playerPosHeight + playerPosHeight * 0.5;
                    if (tempy > this.playerUpPosLimit)
                    {
                        minR = r;
                        break;
                    }
                }
                let posList:GridPos[] = [];
                for (let r = minR; r <= maxR; r++)
                {
                    for (let c = 0; c <= maxC; c++)
                    {
                        posList.push(new GridPos(r, c));
                    }
                }


                // -------------------------------------  Create Players  ----------------------------------------
                for (let i = 0; i < this.currentPlayerNum; i++)
                {   
                    if(this.bDebugInfo)
                    {
                        // console.log("年兽 " + i);
                    }
                    // 随机行列
                    if (posList.length < 0)
                    {
                        break;
                    } 
                    let posListIndex = Math.floor(Math.random() * posList.length);
                    let pos:GridPos = posList[posListIndex];
                    // let r = Math.floor(minR + Math.random() * (maxR - minR));
                    // let c = Math.floor(Math.random() * maxC);
                    let r = pos.row;
                    let c = pos.col;
                    posList[posListIndex] = posList[posList.length - 1];
                    posList.pop();

                    // 得到行列位置
                    let x = c * playerPosWidth + playerPosWidth * 0.5;
                    let y = r * playerPosHeight + playerPosHeight * 0.5;

                    let player = this.CreatePlayer(x, y, r); 
                    let finalRow = this.FixPlayerPos(player, playerPosWidth, playerPosHeight);
                    if (playerList[r] == null)
                    {
                        playerList[r] = [];
                    }
                    playerList[r][playerList[r].length] = player;
                    if(this.bDebugPlayer)
                    {
                        this.DrawLine(this.stage.stageWidth * 0.5, this.stage.stageWidth * 0.5, player.x, player.y);
                    }
                }
            }

            // ------------------------------------------ Create Buildings  --------------------------------------------------------------
            // 按照从上到下一行行的顺序生成
            // console.log("level : " + this.level + "  row : " + this.row + " col:" + this.col);
            for (let r = 0; r < this.row; r++)
            {
                let y = r * this.buildingHeight / 2;
                for (let c = 0; c < this.col; c++)
                {
                    let x = c * this.buildingWidth + (bEven?0:this.buildingWidth/2);

                    // 建筑名
                    let buildingName; 
                    // if (r == 0 || c == 0 || r == this.row - 1 || c == this.col - 1)   //周边的建筑随机
                    let debugLineIndex;
                    // debugLineIndex = this.GetLineIndex(r, c);
                    // debugLineIndex = this.GetLineIndexOppo(r, c, this.col);
                    debugLineIndex = r;

                    // 根据地图数据创建地图
                    let currentMapData = Map.MapData.data[this.level];
                    let num = r * this.col + c;
                    let buildNameIndex = currentMapData[num];
                    // console.log(r + "," + c + "  " + num + " --- " + buildNameIndex);
                    // 车名
                    let carName = "";
                    if (0.6 < Math.random())
                    {
                        carName = carNames[carIndex] + "_png";
                        carIndex = (carIndex + 1) % carNames.length;
                    }

                    // console.log(r * col + c + " , " + r + " " + c, " , ", x, " ", y, " ", bEven);
                    
                    let building = this.createBuilding(x, y, buildNameIndex, carName, addIndex);
                    addIndex += 1;
                }
                if (null != playerList[r])
                {
                    for (let i = 0; i < playerList[r].length; i++)
                    {
                        this.addChild(playerList[r][i]);
                        let player = playerList[r][i];

                        // var label:egret.TextField = new egret.TextField();
                        // label.background = true;
                        // label.backgroundColor = 0xffffff;
                        // label.border = false;
                        // label.borderColor = 0x00ff00;
                        // label.fontFamily = "Arial";
                        // label.textColor = 0x000000;
                        // label.size = 30;
                        // // label.text = index.toString();
                        // label.text = addIndex.toString();
                        // addIndex += 1;
                        // // label.text = this.getChildIndex(building).toString();
                        // label.x = playerList[r][i].x;
                        // label.y = playerList[r][i].y;
                        // label.textAlign = "center";
                        // label.verticalAlign = "center";
                        // //添加到显示列表
                        // this.addChild(label);
                    }
                }
                bEven = !bEven;
            }
            return this.row * this.col + this.col;
        }

        public RemovePlayer(player:egret.Bitmap)
        {
            this.removeChild(player);
            this.$render();
            this.currentPlayerNum -= 1;
            this.onTouchCallback(true);
            if (0 >= this.currentPlayerNum)
            {
                this.NextLevel();
            }
        }

        public PlayCatchSound()
        {
            let channel:egret.SoundChannel = this.catchSound.play(0, 1);
            channel.volume = this.effectSoundVolum;
        }

        public PlayCatchAnim(x:number, y:number)
        {
            // var data = RES.getRes("CatchAnimClip_json");
            // var txtr = RES.getRes("CatchAnimClip_png");
            // var mcFactory:egret.MovieClipDataFactory = new egret.MovieClipDataFactory( data, txtr );
            // var mc1:egret.MovieClip = new egret.MovieClip( mcFactory.generateMovieClipData( "Catch") ); 
            // this.addChild( mc1 );
            // mc1.gotoAndPlay(1 ,1);

            let animCatch = new egret.MovieClip(this.mcCatch.generateMovieClipData("Catch"));
            animCatch.x = x;
            animCatch.y = y;
            animCatch.anchorOffsetX = animCatch.width / 2;
            animCatch.anchorOffsetY = animCatch.height / 2;
            animCatch.addEventListener(egret.Event.COMPLETE, (e:egret.Event)=>{
                Game.Instance().removeChild(animCatch);
            }, animCatch);
            this.addChild(animCatch);
            animCatch.gotoAndPlay(1, 1);            
        }

        // 创建玩家
        public CreatePlayer(x:number, y:number, index):egret.Bitmap
        {
            let player = this.createBitmapByName("Player_png");
            player.width = this.playerWidth;// 619;
            player.height = player.texture.textureHeight / player.texture.textureWidth * player.width;// 358;
            
            player.anchorOffsetX = player.width * 0.5;
            player.anchorOffsetY = player.height * 0.7;
            player.x = x;
            player.y = y;
            // player.x = x + this.buildingWidth * 0.25;
            // player.y = y + this.buildingHeight * 0.25;
            // this.addChild(player);
            player.touchEnabled = true;
            player.addEventListener(egret.TouchEvent.TOUCH_BEGIN,
            function(e:egret.TouchEvent):void{
                Game.Instance().PlayCatchSound();
                Game.Instance().PlayCatchAnim(player.x, player.y);
                Game.Instance().RemovePlayer(player);
            },
            player);
            
            //创建 TextField 对象
            // if (this.bDebugPlayer)
            // {
            //     var label:egret.TextField = new egret.TextField();
            //     label.background = true;
            //     label.backgroundColor = 0xffffff;
            //     label.border = false;
            //     label.borderColor = 0x00ff00;
            //     label.fontFamily = "Arial";
            //     label.textColor = 0x000000;
            //     label.size = 30;
            //     label.text = index.toString();
            //     // label.text = lineIndex.toString();
            //     // label.text = this.getChildIndex(player).toString() + "," + Math.floor(player.y);
            //     label.x = x;
            //     label.y = y;
            //     label.textAlign = "center";
            //     label.verticalAlign = "center";
            //     //添加到显示列表
            //     this.addChild(label);
            //     this.setChildIndex(label, 1000);
            // }
            
            return player;
        }

        // 修正位置
        public FixPlayerPos(player:egret.Bitmap, dw:number, dh:number)
        {
            if (player.x > this.stage.stageWidth - player.width)
            {
                player.x -= dw;
                // console.log(player.x + " " + player.y + " w:" + w);
            }
            if (player.y > this.stage.stageHeight)
            {
                player.y -= dh;
                // console.log(player.x + " " + player.y + " h:" + h);
            }else
            {
                if (player.y < this.playerUpPosLimit)
                {
                    player.y += dh;
                }
            }
            if (player.x > this.stage.stageWidth || player.y > this.stage.stageHeight || player.y < this.playerUpPosLimit)
            {
                this.FixPlayerPos(player, dw, dh);
            }else
            {
                // console.log("-- " + player.x + " " + player.y + " " + this.stage.stageWidth + " " + this.stage.stageHeight);
            }
        }

        // 获取斜对角计算是第几个
        public GetLineIndex(row:number, col:number):number
        {
            return (row%2 == 0 ? row : row + 1) / 2 + col;
        }

        // 获取反斜对角是第几个
        public GetLineIndexOppo(r:number, c:number, col:number):number
        {
            c = (r % 2 == 0 ? (col - c) : (col - c - 1) );
            return (r%2 == 0 ? r : r + 1) / 2 + c;
        }



        // 创建建筑 位置(x,y) 大小(w,H(w)) 
        public createBuilding(x:number, y:number, buildNameIndex:number, carName:string, lineIndex:number):egret.Bitmap
        {
            if (null == buildNameIndex)
            {
                buildNameIndex = 0;
            }
            let buildName = Map.MapData.buildName[buildNameIndex] + "_png";

            let halfBuildWidth = this.buildingWidth / 2;
            let HalfBuildHeight = this.buildingHeight / 2;

            // 地皮名   let groundNames:string[] = ["GA", "GB", "GC", "GD", "GE"];
            let groundName = "G" + buildName.charAt(0) + "_png";
            // 创建地皮
            let ground = this.createBitmapByName(groundName);
            ground.width = this.buildingWidth;// 619;
            ground.height = ground.texture.textureHeight / ground.texture.textureWidth * this.buildingWidth;// 358;
            ground.anchorOffsetX = halfBuildWidth;
            ground.anchorOffsetY = ground.height - HalfBuildHeight;
            ground.x = x;
            ground.y = y;
            this.addChild(ground);
            this.setChildIndex(ground, 0);
            
            // 创建建筑
            let building = this.createBitmapByName(buildName);
            building.width = this.buildingWidth;
            building.height = building.texture.textureHeight / building.texture.textureWidth * this.buildingWidth;
            building.anchorOffsetX = halfBuildWidth;
            building.anchorOffsetY = building.height - HalfBuildHeight;
            building.x = x;
            building.y = y;
            this.addChild(building);
            // this.$render();
            if (this.bEditor)
            {
                Editor.Instance().GetNewBuilding(ground, building, buildNameIndex);
            }

            //创建 TextField 对象
            if (this.bDebugBuilding)
            {
                var label:egret.TextField = new egret.TextField();
                label.background = true;
                label.backgroundColor = 0xffffff;
                label.border = false;
                label.borderColor = 0x00ff00;
                label.fontFamily = "Arial";
                label.textColor = 0x000000;
                label.size = 30;
                // label.text = index.toString();
                label.text = lineIndex.toString();
                // label.text = this.getChildIndex(building).toString();
                label.x = x;
                label.y = y;
                label.textAlign = "center";
                label.verticalAlign = "center";
                //添加到显示列表
                this.addChild(label);
                this.setChildIndex(label, 1000);
            }
            
            // 创建车
            if (this.bCreateCar)
            {
                if(carName != "")
                {
                    let car = this.createBitmapByName(carName);
                    let CStart = carName.indexOf("C");
                    if (CStart == 0)    // 以CAR开头
                    {
                        car.width = this.buildingWidth * 0.2;// 619;
                    }else
                    {
                        car.width = this.buildingWidth * 0.05;
                    }
                    car.height = car.texture.textureHeight / car.texture.textureWidth * car.width;// 358;
                    car.anchorOffsetX = car.width / 2;
                    car.anchorOffsetY = car.height / 2;
                    car.x = x + this.buildingWidth * 0.15;
                    car.y = y + this.buildingHeight * 0.35;
                    this.addChild(car);
                    this.setChildIndex(car, 1000);
                }
            }
            return ground;
        }


        // 创建漂浮气球
        protected createFloatAnim(cityNum:number): void 
        {
            let floatName:string[]=["float_0", "float_1", "float_2", "float_3"];
            let floatNum = Math.floor(cityNum * 0.4);
            let floatWidth = this.buildingWidth * 0.1;
            let index = 0;
            for (let i = 0; i < floatNum; i++)
            {
                let float = this.createBitmapByName(floatName[index] + "_png");
                this.addChild(float);
                float.width = floatWidth * (Math.random() * 1.3 + 0.4);// 619;
                float.height = float.texture.textureHeight / float.texture.textureWidth * float.width;// 358;
                float.anchorOffsetX = float.width*0.5;
                if(index == 2)
                {
                    float.anchorOffsetY = float.height*0.7;
                }else
                {
                    float.anchorOffsetY = float.height*0.2;
                }
                float.x = this.stage.stageWidth * 0.05 + Math.random() * this.stage.stageWidth * 0.9;
                float.y = this.stage.stageHeight * 0.05 + Math.random() * this.stage.stageHeight * 0.9;
                
                if(index <= 1)
                {
                    let drotation = 10;
                    let drotationTime = 3000;
                    let dx = 10;

                    let startRot = drotation * (Math.random() * 2 - 0.5);
                    float.rotation = startRot;
                    let startx = float.x;

                    let twRot = egret.Tween.get( float, { loop:true, onChangeObj:float} );
                    let pect = (drotation - startRot) / (drotation * 2);
                    let firstTime = drotationTime * (pect);
                    twRot.to( {rotation:drotation, }, firstTime, egret.Ease.sineIn)
                        .to( {rotation:-drotation, }, drotationTime, egret.Ease.sineInOut)
                        .to( {rotation:startRot, }, drotationTime - firstTime, egret.Ease.sineInOut);                        

                    var twPos = egret.Tween.get( float, {onChangeObj:float});
                    let twTime = 100000 * (float.y / this.stage.stageHeight);
                    twPos.to( {y:-100}, twTime , egret.Ease.sineIn)
                }else if (index == 2 || index == 3)
                {
                    let drotation = 5;
                    let rand = Math.random();
                    let drotationTime = rand * 1000 + 1000;
                    let dx = 5 + rand * 2;

                    let startRot = drotation * (Math.random() * 2 - 0.5);
                    float.rotation = startRot;
                    let startx = float.x;

                    let twRot = egret.Tween.get( float, { loop:true, onChangeObj:float} );
                    let pect = (drotation - startRot) / (drotation * 2);
                    let firstTime = drotationTime * (pect);
                    if (Math.random() > 0.5)
                    {
                        twRot.to( {rotation:drotation, x:float.x + dx}, drotationTime)
                            .to( {rotation:-drotation, x:float.x - dx}, drotationTime * 2, egret.Ease.sineInOut)
                            .to( {rotation:startRot, x:startx}, drotationTime - firstTime);                        
                    }else
                    {
                        twRot.to( {rotation:drotation, x:float.x - dx}, drotationTime)
                            .to( {rotation:-drotation, x:float.x + dx}, drotationTime * 2, egret.Ease.sineInOut)
                            .to( {rotation:startRot, x:startx}, drotationTime - firstTime);                        
                    }
                }

                index = (index + 1) % 4;
            }
        }    

        public createTopUIGroup(x:number, y:number, radus:number, str:string):egret.TextField
        {
            let rect = new egret.Shape();
            rect.graphics.beginFill(0xf9644e, 1);
            rect.graphics.drawRoundRect(0, 0, radus * 4, radus, radus);
            rect.graphics.endFill();
            rect.x = x;
            rect.y = y;
            this.addChild(rect);

            let circle = new egret.Shape();
            rect.graphics.beginFill(0xaaaaaa, 1);
            rect.graphics.drawCircle(0, 0, radus);
            rect.graphics.endFill();
            rect.x = x;
            rect.y = y;
            this.addChild(rect);

            //创建 TextField 对象
            var label:egret.TextField = new egret.TextField();
            label.background = false;
            label.backgroundColor = 0x000000;
            label.border = false;
            label.borderColor = 0x00ff00;
            label.fontFamily = "Arial";
            label.textColor = 0xffffff;
            label.size = 30;
            label.text = str;
            label.x = x + radus * 2;
            label.y = y + 10;
            label.textAlign = "center";
            label.verticalAlign = "center";
            //添加到显示列表
            this.addChild(label);
            return  label;
        }


        /**
         * 根据name关键字创建一个Bitmap对象。name属性请参考resources/resource.json配置文件的内容。
         * Create a Bitmap object according to name keyword.As for the property of name please refer to the configuration file of resources/resource.json.
         */
        private createBitmapByName(name: string): egret.Bitmap {
            let result = new egret.Bitmap();
            let texture: egret.Texture = RES.getRes(name);
            result.texture = texture;
            return result;
        }

        private catchSound:egret.Sound;
        private mcCatch:egret.MovieClipDataFactory;

        private Pointer:egret.Bitmap;
        private Player:egret.Bitmap;
        private TextLevel:egret.TextField;
        private levelNum:number = 15;       // 关卡数
        private firstLevelWidth = 600;
        private lastLevelWidth = 150;
        private row:number = 0;
        private col:number = 0;
        public level:number = 0;
        private startLevel:number = 0;          // 开始关卡
        private buildingWidth = 0;
        private buildingHeight = 0;

        private bCreateCar:boolean = true;  // 是否创建车和行人
        private bCreateFloat:boolean = true; // 是否创建气球和灯笼
        private bEditor = false;
        private bHasUI:boolean = false;         // 是否显示UI

        private bDebugBuilding = false;              // 是否显示Debug线
        private bDebugPlayer = false;              // 是否显示Debug线
        private bDebugInfo = true;

        private pointerScale:number = 0.8;      // 鼠标图标大小比例

        private currentPlayerNum = 0;
        private playerUpPosLimit = 150;
        private playerScale:number = 0.2;
        private playerWidth:number = 0;

        public effectSoundVolum = 0.5;  // 音效音量大小 (0~1)
    }
        const scal = 358/619; // 长款比
}

